//
//  TMComplaintTypeController.m
//  国学培训用户端
//
//  Created by Tao Li on 2018/9/15.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "TMComplaintTypeController.h"
#import "VTMagic.h"
#import "TMComplaintListController.h"
@interface TMComplaintTypeController ()<VTMagicViewDataSource,VTMagicViewDelegate>
@property (nonatomic, strong) VTMagicController *magicController;
@end

@implementation TMComplaintTypeController
- (VTMagicController *)magicController
{
    if (!_magicController) {
        _magicController = [[VTMagicController alloc] init];
        _magicController.view.translatesAutoresizingMaskIntoConstraints = YES;
        _magicController.magicView.navigationColor = [UIColor whiteColor];//导航栏的颜色
        
        _magicController.magicView.switchStyle = VTSwitchStyleDefault;
        _magicController.magicView.layoutStyle = VTLayoutStyleDivide;
        _magicController.magicView.headerHidden = NO;
        _magicController.magicView.againstStatusBar = NO;
        _magicController.magicView.sliderExtension = 10.0;
        _magicController.magicView.sliderColor = [UIColor hx_colorWithHexRGBAString:@"#05B48D"];
        _magicController.magicView.dataSource = self;
        _magicController.magicView.delegate = self;
        _magicController.magicView.itemScale = 1.1;//点中的item变大
    }
    return _magicController;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"我的投诉";
    self.edgesForExtendedLayout = UIRectEdgeAll;
    [self addChildViewController:self.magicController];
    [self.view addSubview:_magicController.view];
    [self.view setNeedsUpdateConstraints];
    [_magicController.magicView reloadData];
}

- (NSArray<__kindof NSString *> *)menuTitlesForMagicView:(VTMagicView *)magicView{
    return @[@"平台投诉",@"商家投诉"];
}

- (UIButton *)magicView:(VTMagicView *)magicView menuItemAtIndex:(NSUInteger)itemIndex
{
    static NSString *itemIdentifier = @"itemIdentifier";
    UIButton *menuItem = [magicView dequeueReusableItemWithIdentifier:itemIdentifier];
    if (!menuItem) {
        menuItem = [UIButton buttonWithType:UIButtonTypeCustom];
        [menuItem setTitleColor:[UIColor hx_colorWithHexRGBAString:@"#3B3B3B"] forState:UIControlStateNormal];
        [menuItem setTitleColor:[UIColor hx_colorWithHexRGBAString:@"#05B48D"] forState:UIControlStateSelected];
        menuItem.titleLabel.font = [UIFont fontWithName:@"Helvetica" size:16.f];
    }
    return menuItem;
}

- (UIViewController *)magicView:(VTMagicView *)magicView viewControllerAtPage:(NSUInteger)pageIndex{
    static NSString *gridId = @"grid.identifier";
    TMComplaintListController *gridViewController = [magicView dequeueReusablePageWithIdentifier:gridId];
    if (!gridViewController) {
        gridViewController = [[UIStoryboard storyboardWithName:@"Mine" bundle:nil] instantiateViewControllerWithIdentifier:@"TMComplaintListController"];
    }
    gridViewController.type = (NSInteger)pageIndex +1;
    return gridViewController;
}

@end
